package com.atguigu.interview.study.thread;

import java.util.concurrent.atomic.AtomicInteger;

/**
 *
 * @author gcq
 * @Create 2020-10-25
 *
 * 1、CAS 是什么？ ==> compareAndSet
 *  比较并交换
 */
public class CASDemo {
    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger(5);
        //expect 期望值 update 更新值
        System.out.println(atomicInteger.compareAndSet(5, 2019) + "\t current data:" + atomicInteger.get());
        System.out.println(atomicInteger.compareAndSet(5, 2019) + "\t current data:" + atomicInteger.get());
//        atomicInteger.getAndIncrement(1);
    }
}